// Copyright (c) 2009, Michael Patraw
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * The name of Michael Patraw may not be used to endorse or promote 
//       products derived from this software without specific prior written
//       permission.
//
// THIS SOFTWARE IS PROVIDED BY Michael Patraw ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL Michael Patraw BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ITEMS_H
#define ITEMS_H

#include <vector>

#include "glyph.h"

typedef unsigned long long type_t;

// Type.
#define TYPE_NONE    (1 << 0)
#define TYPE_STONE   (1 << 1)
#define TYPE_PLANT   (1 << 2)
#define TYPE_CLAY    (1 << 3)
#define TYPE_LIQUID  (1 << 4)
#define TYPE_COVER   (1 << 5)
#define TYPE_POLE    (1 << 6)
#define TYPE_SHARP   (1 << 7)
#define TYPE_BLUNT   (1 << 8)
#define TYPE_BURNS   (1 << 9)
#define TYPE_ELASTIC (1 << 10)

// ID.
enum
{
    ID_NONE,
    ID_HAND,
    ID_HEAD,
    ID_BODY,
    ID_LEGS,
    ID_FEET,
};

class Item
{
public:
    Item(const char * name, int id=0, type_t type=0, int warmth=0, int health=0, int attack=0, int defense=0);
    virtual ~Item();
    
    virtual int getId() const;
    virtual type_t getType() const;
    virtual bool isType(type_t type) const;
    
    virtual int getWarmth() const;
    virtual int getHealth() const;
    virtual int getAttack() const;
    virtual int getDefense() const;
    virtual const char * getName() const;

    bool operator ==(const Item & it);
protected:
    const char * name_;
    int id_; // What the item can be used as.
    type_t type_; // Used for item creation tables.
    int warmth_;
    int health_;
    int attack_;
    int defense_;
};

class ItemList
{
public:
    ItemList(int maxsize=-1);
    ~ItemList();

    int numItems() const;
    Item * getItem(int n);
    void * setItem(int n, Item * item);
    Item * remItem(int n); // Must be deallocated.
    void   delItem(int n);
    bool   addItem(Item * item);
    
    bool isEmpty() const;
    bool isFull() const;
private:
    std::vector<Item *> items_;
    int maxsize_;
};

#endif // ITEMS_H
